//
//  JiaobanViewController.m
//  bluetooth
//
//  Created by 周季阳 on 15/7/13.
//  Copyright (c) 2015年 switch. All rights reserved.
//

#import "JiaobanViewController.h"
#import "OLImage.h"
#import "OLImageView.h"
#import "UIViewAdditions.h"
#import "AppDelegate.h"
#import "FenkaiViewController.h"
#import "ShopViewController.h"
@interface JiaobanViewController ()
{
    OLImageView *Aimv;
}
@end

@implementation JiaobanViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self createrView];
}
#pragma mark - initUI
-(void)createrView{
    UIImageView * imgView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"制作完成.png"]];
    [imgView setFrame:[UIScreen mainScreen].bounds];
    [self.view addSubview:imgView];
    imgView.userInteractionEnabled = YES;
    
    UIButton *leftBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    leftBtn.frame = CGRectMake(10, 40, 78, 26);
    [leftBtn setBackgroundImage:[UIImage imageNamed:@"15清洗-清洁导流槽_03(1)"] forState:UIControlStateNormal];
    [leftBtn addTarget:self action:@selector(clickLeftBtn) forControlEvents:UIControlEventTouchUpInside];
    [imgView addSubview:leftBtn];
    
    UIButton *rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    rightBtn.frame = CGRectMake(SCREEN_WIDTH-88, 40, 78, 26);
    [rightBtn setBackgroundImage:[UIImage imageNamed:@"制作完成_05"] forState:UIControlStateNormal];
    [rightBtn addTarget:self action:@selector(clickRightBtn) forControlEvents:UIControlEventTouchUpInside];
    [imgView addSubview:rightBtn];
    
    UIImageView *dianImage = [[UIImageView alloc]initWithFrame:CGRectMake(20, leftBtn.bottom+53, 5, 5)];
    dianImage.image = [UIImage imageNamed:@"dian"];
    [imgView addSubview:dianImage];
    
    
    UILabel *zTitle = [[UILabel alloc]initWithFrame:CGRectMake(dianImage.right+5, leftBtn.bottom+40, SCREEN_WIDTH-40, 40)];
    zTitle.textColor = [UIColor whiteColor];
    zTitle.backgroundColor = [UIColor clearColor];
    zTitle.textAlignment = NSTextAlignmentLeft;
    zTitle.numberOfLines = 0;
    zTitle.text = @"将搅拌箱向上提取出";
    zTitle.font = [UIFont systemFontOfSize:16];
    [imgView addSubview:zTitle];
    
    Aimv = [OLImageView new];
    
    NSString *filePath = [[NSBundle mainBundle] pathForResource:@"12清洗-取出搅拌箱" ofType:@"gif"];
    NSData *GIFDATA = [NSData dataWithContentsOfFile:filePath];
    Aimv.image = [OLImage imageWithData:GIFDATA];
    Aimv.userInteractionEnabled = YES;
    [Aimv setFrame:[UIScreen mainScreen].bounds];
    [Aimv setFrame:CGRectMake((SCREEN_WIDTH-284)/2, leftBtn.bottom+100, 284, 279)];
    
    [self.view addSubview:Aimv];
    
    
    UIButton *actionBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    actionBtn.frame = CGRectMake((SCREEN_WIDTH-93)/2, SCREEN_HEIGHT-94, 93, 84);
    [actionBtn setBackgroundImage:[UIImage imageNamed:@"制作完成_14"] forState:UIControlStateNormal];
    [actionBtn addTarget:self action:@selector(clickSure) forControlEvents:UIControlEventTouchUpInside];
    [imgView addSubview:actionBtn];
    
    
    
}
#pragma mark - 确定
-(void)clickSure{
    //[self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:2] animated:YES];
    
    AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
    appDelegate.isWhere = @"16";
    FenkaiViewController *last = [[FenkaiViewController alloc]init];
    [self.navigationController pushViewController:last animated:YES];
    
}
#pragma mark - 返回上一步
-(void)clickLeftBtn{
//    AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
//    appDelegate.isWhere = @"14";
//    [self.navigationController popViewControllerAnimated:YES];
    ShopViewController *shop  = [[ShopViewController alloc]init];
    [self.navigationController pushViewController:shop animated:YES];
}
#pragma mark - 退出
-(void)clickRightBtn{
    UIAlertView *alert = [[UIAlertView alloc]initWithTitle:nil message:@"您确定退出么" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:@"取消", nil];
    [alert show];
}
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
    if (buttonIndex == 0) {
        [[NSNotificationCenter defaultCenter]postNotificationName:@"cleanUp" object:nil];
        [self.navigationController popToRootViewControllerAnimated:YES];
    }
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
-(void)viewDidDisappear:(BOOL)animated{
    [Aimv removeFromSuperview];
    Aimv = nil;
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
